package cn.edu.ctbu.dp07.service.impl;

import cn.edu.ctbu.dp07.dao.StudentDao;
import cn.edu.ctbu.dp07.entity.Student;
import cn.edu.ctbu.dp07.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;
    
    @Override
    public List<Student> findAll() {
        return studentDao.findAll();
    }
    
    @Override
    public Student findById(Integer id) {
        return studentDao.findById(id).orElse(null);
    }
    
    @Override
    public Student findByStudentNo(String studentNo) {
        return studentDao.findByStudentNo(studentNo);
    }
    
    @Override
    public Iterable<Student> findByNameContaining(String name) {
        return studentDao.findByNameContaining(name);
    }
    
    @Override
    public Student save(Student student) {
        return studentDao.save(student);
    }
    
    @Override
    public void deleteById(Integer id) {
        studentDao.deleteById(id);
    }
} 